{% extends "app/base_site.html" %}

{% block title %} 系统设置 {% endblock title %}
{% block stylesheets %}
  {{ block.super }}
<style>
    input[type="file"]{
      color: #3a3636;
      font-size: 12px;
    }
    ::file-selector-button{
      font-size: 12px;
      color: #fff;
      border-radius: 4px;
      border: 1px solid #8f9093;
      padding: 2px 4px;
      background-color: #8f9093;
      cursor: pointer;
    }

</style>
{% endblock stylesheets %}

{% block content %}
  <div class="right_col" role="main">
    <div class="">
      <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
          <div class="x_panel">
            <div class="x_title">
              <h2>系统设置
                <span id="top_loading" ><img class="top_loading_img" src="/static/images/load.gif" alt="loading">加载中</span>
                <span id="top_msg">{{top_msg}}</span>
              </h2>
              <div class="clearfix"></div>
            </div>
            <div class="x_content">

                <div class="form-horizontal form-label-left" >

                    <div class="ln_solid"></div>
                      <div class="form-group">
                         <div class="col-md-6 col-sm-6 col-md-offset-3">
                                <h4 style="font-weight: bold">日志</h4>
                             <button type="button" onclick="f_export_logs()" class="btn btn-primary btn-sm" >导出日志</button> 导出日志，提供给开发者排查问题
                          </div>
                    </div>



                </div>

            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
{% endblock content %}

{% block javascripts %}
  {{ block.super }}
<script>
    let ele_top_loading = $("#top_loading");
    let ele_top_msg= $("#top_msg");
    let eleFile = $("input[name='file']");

    function f_export_logs(){
        //导出日志
        ele_top_loading.show();
        $.ajax({
           url: "/system/postExportLogs",
           type: "post",
           async: true,
           data: {},
           dataType: "json",
           timeout: 0,
           error: function () {
               ele_top_loading.hide();
               myAlert("网络异常，请确定网络正常！","error");
           },
           success: function (res) {
               ele_top_loading.hide();
               if(1000 === res.code){
                    let info = res.info;
                    let export_filename = info["export_filename"]
                    let download_url = "/storage/download?filename="+export_filename;
                    window.open(download_url);
               }else{
                   myAlert(res.msg,"error",3000);
               }
           }
        });

    }


</script>

{% endblock javascripts %}
